package com.hnust.aopdemo.chain;

import sun.applet.Main;

public class Client {
    static class HandlerA extends Handler{

        @Override
        protected void handleProcess() {
            System.out.println("handleProcess：handle by a");
        }
    }

    static class HandlerB extends Handler{

        @Override
        protected void handleProcess() {
            System.out.println("handleProcess：handle by b");
        }
    }

    static class HandlerC extends Handler{

        @Override
        protected void handleProcess() {
            System.out.println("handleProcess：handle by c");
        }
    }

    public static void main(String[] args) {
        Handler handlerA = new HandlerA();
        Handler handlerB = new HandlerB();
        Handler handlerC = new HandlerC();

        //设置链式从属关系
        handlerA.setSuccess(handlerB);
        handlerB.setSuccess(handlerC);

        //只关系并调用头一个对象的方法
        handlerA.execute();
    }
}
